package com.cbtx.receiver

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter

/**
 * author : joker.peng
 * e-mail : joker@fiture.com
 * date   : 2021/7/1 3:43 PM
 * desc   :
 */
abstract class BaseReceiver constructor(private val context: Context) : BroadcastReceiver() {

    var iReceiverManager: IReceiverManager? = null

    init {
        iReceiverManager = ReceiverManager(context)
    }

    override fun onReceive(context: Context?, intent: Intent?) {
        if (intent == null || context == null) return
        if (iReceiverManager == null) return
        if (intent.action.isNullOrEmpty()) return
    }

    abstract fun initIntentFilter(): IntentFilter

    open fun register() {
        context.registerReceiver(this, initIntentFilter())
    }

    open fun unRegister() {
        context.unregisterReceiver(this)
    }

}